package com.tj.test.sys.tool;

/*返回类型所调用的方法*/
public class Result {

    /*有关业务成功后的信息包装*/
    public static ResponseMessage success(String respmsg){
        return new ResponseMessage (ResponseMessageCodeEnum.SUCCESS.getCode(),respmsg,true);
    }
    public static <T> ResponseMessage<T>  success(String respcode,T data ){
        return new ResponseMessage<>(respcode,"",data,true);
    }
    public static <T> ResponseMessage<T>  success(String respcode,String respmsg ){
        return new ResponseMessage<>(respcode,respmsg);
    }
    public static <T> ResponseMessage<T>  success(String respcode,String respmsg ,boolean flag,T data){
        return new ResponseMessage<>(respcode,respmsg,data,flag);
    }
    public static <T> ResponseMessage<T>  success(T data){
        return new ResponseMessage<>(ResponseMessageCodeEnum.SUCCESS.getCode(),"",data,true);
    }

    /*有关业务失败后的信息包装*/
    public static ResponseMessage error(String respmsg){
        return new ResponseMessage (ResponseMessageCodeEnum.ERROR.getCode(),respmsg,true);
    }
    public static <T> ResponseMessage<T>  error(String respcode,T data ){
        return new ResponseMessage<>(respcode,"",data,true);
    }
    public static <T> ResponseMessage<T>  error(String respcode,String respmsg ){
        return new ResponseMessage<>(respcode,respmsg);
    }
    public static <T> ResponseMessage<T>  error(String respcode,String respmsg ,boolean flag,T data){
        return new ResponseMessage<>(respcode,respmsg,data,flag);
    }
    public static <T> ResponseMessage<T>  error(T data){
        return new ResponseMessage<>(ResponseMessageCodeEnum.ERROR.getCode(),"",data,true);
    }
}
